package com.huawei.od;

import java.util.ArrayList;
import java.util.List;

/**
 * A，B两个人玩一个数字比大小的游戏，在游戏前，两个人会拿到相同长度的两个数字序列，两个数字序列不相同的，且其中的数字是随机的。
 */
public class T2 {
    public static void main(String[] args) {
        int[] A = new int[3];
        A[0] = 8;
        A[1] = 4;
        A[2] = 4;

        int[] B = new int[3];
        B[0] = 3;
        B[1] = 6;
        B[2] = 4;

        int max = maxWin(A, B);
        System.out.println(max);
    }

    private static int maxWin(int[] A, int[] B) {
        int win = 0;
        A = ascArr(A);
        B = descArr(B);
        List<Integer> listA = new ArrayList<>();
        List<Integer> listB = new ArrayList<>();

        for (int i = 0; i < A.length; i++) {
            for (int j = 0; j < B.length; j++) {
                if (!listA.contains(i) && !listB.contains(j) && A[i] > B[j]) {
                    win++;
                    listA.add(i);
                    listB.add(j);
                }
            }
        }

        return win;
    }

    private static int[] descArr(int[] A) {
        for (int i = 0; i < A.length - 1; i++) {
            for (int j = i + 1; j < A.length; j++) {
                if (A[i] < A[j]) {
                    int temp = A[i];
                    A[i] = A[j];
                    A[j] = temp;
                }
            }
        }
        return A;
    }

    private static int[] ascArr(int[] A) {
        for (int i = 0; i < A.length - 1; i++) {
            for (int j = i + 1; j < A.length; j++) {
                if (A[i] > A[j]) {
                    int temp = A[i];
                    A[i] = A[j];
                    A[j] = temp;
                }
            }
        }
        return A;
    }
}
